#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR

if [ ! -d dev_cache  ];then
  mkdir dev_cache
  chmod a+rw dev_cache
fi

if [ ! -d dev_cache/database  ];then
  mkdir dev_cache/database
  chmod a+rw dev_cache/database
fi

if [ ! -d dev_cache/runtime  ];then
  mkdir dev_cache/runtime
  chmod a+rw dev_cache/runtime
fi

if [ ! -d dev_cache/data  ];then
  mkdir dev_cache/data
  chmod a+rw dev_cache/data
fi

if [ ! -f dev_cache/.gitignore  ];then
  echo '*' > dev_cache/.gitignore
  echo '!.gitignore' >> dev_cache/.gitignore
  chmod a+rw dev_cache/.gitignore
fi

sudo docker-compose -f "./docker/docker-compose.yml" up
sudo docker-compose -f "./docker/docker-compose.yml" rm -f
